package com.example.administrator.dc.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.dc.Bean.Clublist;
import com.example.administrator.dc.R;
import com.example.administrator.dc.adapter.ClubListAdapter;
import com.example.administrator.dc.model.ListModel;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * A simple {@link Fragment} subclass.
 */
public class ClubCenterFragment extends Fragment {
    private RecyclerView clublist;



    public void onViewCreated(View view,@Nullable Bundle savedInstanceState) {

        frist();
        second();
        third();


    }
    private  void  frist(){
        clublist= (RecyclerView) getView().findViewById(R.id.clublist);
        clublist.setLayoutManager(new LinearLayoutManager(this.getActivity()));
    }
    private  void  second(){
        ListModel listModel=new ListModel();
        Call<List<Clublist>> call=listModel.Club("1","1");
        call.enqueue(new Callback<List<Clublist>>() {
            @Override
            public void onResponse(Call<List<Clublist>> call, Response<List<Clublist>> response) {
                List<Clublist> res=response.body();

                clublist.setAdapter(new ClubListAdapter(getActivity(),res));





            }

            @Override
            public void onFailure(Call<List<Clublist>> call, Throwable t) {

            }
        });



    }
    private void  third(){

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_blank, container, false);
    }

}
